<template>
	<view class="mainpadding2">
		<view class="mainpadding_top ffffff radius" v-for="item in list.data" :key="item.id">
			<view class="flexbetween">
				<view class="flexleft">
					<image :src="item.avatar" mode="" class="listheadplimg"></image>
					<view class="flexcolumnbet" style="height: 70rpx;">
						<view class="xiaohei margin_left1">{{item.nickname}}</view>
						<view class="xiaohui margin_left1">{{item.createtime_text}}</view>
					</view>
				</view>
				<view class="flexright xiaolan">
					<view class="haopings" v-if="item.composite_evaluate==5"></view>
					<view class="zhongpings" v-if="item.composite_evaluate==3"></view>
					<view class="chapings" v-if="item.composite_evaluate==1"></view>
					<view class="margin_left1">{{item.composite_evaluate_text}}</view>
				</view>
			</view>
			<view class="hui_text bold main_size margin_top">{{item.content}}</view>
			<view class="flexleft">
				<view class="itemimgBox flexcenter margin_top" v-for="(ite,inde) in item.images_arr" :key="inde" @click="lbtpriview(inde,item.images_arr)">
					<image class="listleftimg radius" :src="ite" mode=""></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid: "",
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.init()
		},
		methods: {
			lbtpriview(index, arr) {
				var i = arr; //获取当前页面的轮播图数据
				//uniapp预览轮播图
				uni.previewImage({
					current: index, //预览图片的下标
					urls: i //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
				})
			},
			init(isPage, page) {
				let _this = this;
				httpRequest.request('/api/lesson/getcommentlist', 'GET', {
					page: page || 1,
					id: _this.listid,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style>

</style>